package com.xysoft.framework.event;

import org.hibernate.Session;

public class HibernatePostUpdateEvent extends PostUpdateEvent {
	private static final long serialVersionUID = 3399053552377122741L;

	private Object oldEntity;
	private String entityName;
	private Session session;

	public HibernatePostUpdateEvent(Object source, String entityName, Object entity, Session session) {
		super(source, entityName, null, entity);
		this.entityName = entityName;
		this.session = session;
	}

	public Object getOldEntity() {
		if (oldEntity == null) {
			oldEntity = HibernateUtils.loadOldEntity(getEntity(), session);
		}
		return oldEntity;
	}

	public String getEntityName() {
		return entityName;
	}
}
